<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="my" uri="/mytags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>过程管理</title>
 
 
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/asserts/bootstrap-3.3.7-dist/css/bootstrap.min.css"/>
	
	<!-- js插件 -->
		<script src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js"></script>
		<script src="${pageContext.request.contextPath}/asserts/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
        <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/asserts/bootstrapValidate/css/bootstrapValidator.min.css"/>
 	   <script src="${pageContext.request.contextPath}/asserts/bootstrapValidate/js/bootstrapValidator.min.js"></script>
	
	 
</head>
<body>
	<!-- 内容展示区 -->
	<div>
		<!-- 导航 -->
		<ol class="breadcrumb">
			<li><i class="fa fa-comment"></i> 现场图片上传</li>
		</ol>
		<!-- 	内容面板 -->
		<div class="panel panel-default">
			<!-- 控制按钮 -->
			<div class="panel-heading">
				<div class="btn-group">
					<button class="btn btn-primary" id="addSpot">
						<span class="glyphicon glyphicon-pencil"></span>添加
					</button>
				</div>
			</div>
			<!-- 控制按钮  end-->
			<div class="panel-body">
				<form action="${pageContext.request.contextPath}/spot/list"
					method="post" class="form-horizontal">
					<div class="form-group">
									 	 <label class="control-label col-md-2">所属乡镇：</label>
											<div class="col-md-3">
												 		  <select id="zid" name="zid" class="form-control" onchange="changeZhen(this)">
															<option value="">请选择</option>
															<c:forEach var="xz" items="${xzList}">
																<option value="${xz.id}" <c:if test="${xz.id==zid}">selected="selected"</c:if>>${xz.name}</option>
															</c:forEach>
														</select>
											</div>
										<label class="control-label col-md-2">所属学校(先选择乡镇)：</label>
										<div class="col-md-3">
											 <select id="schid" name="schid" class="form-control">
												<option value="">请选择</option>
												  <c:forEach var="school" items="${schoolListByZid}">
										 		   <option value="${school.schid}" <c:if test="${school.schid==schid}">selected="selected"</c:if>>${school.name}(${school.level})</option>
										 		
										 	      </c:forEach>
											</select> 
										</div>
										 
					</div>
					<div class="form-group">
						<%-- <label class="control-label col-md-2">所在学校：</label>
						<div class="col-md-3">
							<select name="schid" class="form-control">
								<option value="">请选择</option>
								<c:forEach var="school" items="${schoolList}">
									<option value="${school.schid}" <c:if test="${school.schid==schid}"> selected="selected" </c:if>>${school.name}(${school.level})</option>

								</c:forEach>
							</select>
						</div> --%>
						<label class="control-label col-md-2"> 状态：</label>
						<div class="col-md-3">
							<select name="status" class="form-control" >
								<option value="" >请选择</option>		
								<option value="1" <c:if test="${status==1}">selected="selected" </c:if>>初稿</option>								
								<option value="2" <c:if test="${status==2}">selected="selected" </c:if>>镇级审核中</option>
								<option value="3" <c:if test="${status==3}">selected="selected" </c:if>>县级审核中</option>
								<option value="4" <c:if test="${status==4}">selected="selected" </c:if>>归档</option>								
							</select>
						</div>
						<div class="col-md-2">
							<button class="btn btn-success">查询</button>
						</div>
					</div>

				</form>

				<table   class="table table-bordered table-striped table-condensed table-hover">
					<tr>
						<th width="10px">序号</th>
						<th width="10%">标题</th>
						<th width="10%">宣传现场图片</th>
						<th width="10%">评审会议现场图片</th>
						<th width="10%">名单公示现场图片</th>
						<th width="10%">签领现场图片</th>						
						<th width="10%">所属学校</th>
						<th width="10%">状态</th>
						<th width="10%">更新时间</th>
						<th width="10%">操作</th>
					</tr>
					<!-- 数据绑定 -->
					<c:forEach items="${pageInfo.list}" var="spot">
						<tr>
							<td width="10px">${spot.id}</td>
							<td>${spot.title}</td>
							<td> 
							<img
							src="../../img/${spot.propagateimg}" style="height: 100px; width: 100px;"
							onmouseover="this.style.cursor='pointer';this.style.cursor='hand'"
							onmouseout="this.style.cursor='default'"
							onclick="showimage('../../img/${spot.propagateimg}')" data-toggle="modal"
							data-target="#ShowImage_Form" />
							</td>
							<td>
							<img
							src="../../img/${spot.meetingimg}" style="height: 100px; width: 100px;"
							onmouseover="this.style.cursor='pointer';this.style.cursor='hand'"
							onmouseout="this.style.cursor='default'"
							onclick="showimage('../../img/${spot.meetingimg}')" data-toggle="modal"
							data-target="#ShowImage_Form" />
							</td>
							<td>
							<img
							src="../../img/${spot.namelistimg}" style="height: 100px; width: 100px;"
							onmouseover="this.style.cursor='pointer';this.style.cursor='hand'"
							onmouseout="this.style.cursor='default'"
							onclick="showimage('../../img/${spot.namelistimg}')" data-toggle="modal"
							data-target="#ShowImage_Form" />
							
							</td>
							<td>
							<img
							src="../../img/${spot.signatureimg}" style="height: 100px; width: 100px;"
							onmouseover="this.style.cursor='pointer';this.style.cursor='hand'"
							onmouseout="this.style.cursor='default'"
							onclick="showimage('../../img/${spot.signatureimg}')" data-toggle="modal"
							data-target="#ShowImage_Form" />
							</td>
							
							<td>${spot.school.name}</td>
							<td><c:if test="${spot.status==1}">初稿</c:if> <c:if
									test="${spot.status==2}">镇级别审核中</c:if> <c:if
									test="${spot.status==3}">县级别审核中</c:if> <c:if
									test="${spot.status==4}">归档</c:if></td>
							<td><fmt:formatDate type="both" dateStyle="medium"
									timeStyle="medium" value="${spot.finishdate}" /></td>
							<td>

								<button type="button" class="btn btn-danger" style="width: 100px;"
									onclick="deleteSpot(${spot.id})">
									<span class="glyphicon glyphicon-remove"></span> 删除
								</button>
							<%-- 	<button type="button" class="btn btn-primary"
									onclick="updateSpot(${spot.id},${spot.status})">
									<span class="glyphicon glyphicon-edit"></span> 修改
								</button> --%>
								<button type="button" class="btn btn-success" style="width: 100px;" onclick="dataUp(${spot.id},${spot.status})">
									<span class="glyphicon glyphicon-upload"></span>
													    <c:if test="${spot.status==3}">数据归档</c:if>
												 		<c:if test="${spot.status!=3}">数据上报</c:if>
								</button>
								<c:if test="${user.roleid!=1}">
									<button type="button" class="btn btn-warning" style="width: 100px;" onclick="dataDown(${spot.id},${spot.status})">
										<span class="glyphicon glyphicon-upload"></span>撤销上报
									</button>
								</c:if>
							</td>
						</tr>
					</c:forEach>

					<!-- 	数据绑定 end -->
				</table>
				<!-- 	分页 -->
				<my:page prePage="${pageInfo.prePage}"
					nextPage="${pageInfo.nextPage}"
					url="${pageContext.request.contextPath}/spot/list?n=1&x=1"
					totalPage="${pageInfo.pages}" currentPage="${pageInfo.pageNum}" />
			</div>
		</div>
		<!-- 内容面板 end -->
	</div>
  <div id="ShowImage_Form" class="modal fade">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal">
				<span>&times;</span>
			</button>
		</div>
		<div class="modal-body">
			<div id="img_show"></div>
		</div>
	</div>
</body>
</html>
<script>
function changeZhen(obj){
	 //ajax   根据镇id 查询 它学校表中的 数据 
	if(obj.value!=''){
		  $.ajax({
				url : '../school/getSchoolByZid?zid='+obj.value,
				type : "get",
				dataType : "json",
				success : function(data) {
					 
					if(data!=null){
						$("#schid option:gt(0)").remove();
						for(var i=0;i<data.length;i++){
							var opt = "<option value='"+data[i].schid+"'>"+data[i].name+"("+data[i].level+")</optoin>";
							$("#schid").append(opt);
						}
					} 
				},
				error : function(xhr) {
					 
				}
			});
	}else{
		$("#schid option:gt(0)").remove();
	}
}
	 $(function () {	  
        $("#addSpot").click(function(){	
   		 location.href="${pageContext.request.contextPath}/addspot.jsp";   		
   	});
        
    });
	 //删除
	 function deleteSpot(id){		   		  	 
			location.href="${pageContext.request.contextPath}/spot/delete?id="+id;	   
		}
	 //修改
	 function updateSpot(id,status){
		if(status!=1){
			alert("状态不为初稿，不能修改");
			return;
		}
	  	location.href= "updateSpot?id="+id;
	}
	 //上报
	 function Report(id){
		 if(status==4){
				alert("状态为归档，不能再次上传");
				return;
			}
		 location.href="${pageContext.request.contextPath}/spot/report?id="+id;
	 }
	 //撤销上报
	 function NoReport(id){
		 if(status==1){
				alert("状态为初稿，不能操作");
				return;
			}
		 location.href="${pageContext.request.contextPath}/spot/noreport?id="+id;
	 }
	 
	 function showimage(source) {
			$("#ShowImage_Form")
					.find("#img_show")
					.html(
							"<center><img src='"+source+"' class='img-responsive img-rounded' /></center>");
			// $("#ShowImage_Form").modal(); 
		}
	 //数据上报
	 function dataUp(id,status){
		
		 var flag  = confirm("确认要上报吗?将由上级领导审批");
		 if(flag){
			  $.ajax({
					type:"post",
					url:"report",
					data:"id="+id+"&status="+status,
					dataType:"JSON",
					success:function(data){
					 
					      if(data.status==200){
					    	  //登录成功
					    	  alert(data.msg);
		 			    	  location.href="list";
					      }else{
					    	 alert(data.msg);
					      }
					}
					
				});
			 
		 }
	  }
	 
	 //数据上报
	 function dataDown(id,status){
		 var flag  = confirm("确认要撤销上报吗?");
		 if(flag){
			  $.ajax({
					type:"post",
					url:"noreport",
					data:"id="+id+"&status="+status,
					dataType:"JSON",
					success:function(data){
					 
					      if(data.status==200){
					    	  //登录成功
					    	  alert(data.msg);
		 			    	  location.href="list";
					      }else{
					    	 alert(data.msg);
					      }
					}
					
				});
		 }
	  }
</script>